# 商业转载请联系作者获得授权，非商业转载请注明出处。
# For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.
# 协议(License)：署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
# 作者(Author)：
# 链接(URL)：http://www.ryuichi.tech/85.html
# 来源(Source)：

#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;
 
int T,N,K;
 
void solve(int n,int k){
	vector<int> ans;
	if(n&1){
		for(int i = 1;i<k;i++){
			ans.push_back(1);
			n-=1;
		}
		if(n%2 == 0 || n<=0) {
			cout<<"NO\n";
			return;
		}else {
			cout<<"YES\n";
			ans.push_back(n);
			for(auto v:ans) cout<<v<<" ";cout<<'\n';
		}
	}else{
		for(int i = 1;i<k;i++){
			ans.push_back(2);
			n-=2;
		}
		if(n%2 == 1 || n<=0) ans.clear();
		else{
			cout<<"YES\n";
			ans.push_back(n);
			for(auto v:ans) cout<<v<<" ";cout<<'\n';
			return ;
		}
		n = N;
		for(int i = 1;i<k;i++){
			ans.push_back(1);
			n-=1;
		}
		if(n%2 == 0 || n<=0) cout<<"NO\n";
		else{
			cout<<"YES\n";
			ans.push_back(n);
			for(auto v:ans) cout<<v<<" ";cout<<'\n';
			return ;
		}
	}
	
}
 
int main(){
	// debug;
	ios;
	cin>>T;
	while(T--){
		cin>>N>>K;
		solve(N,K);
	}
	
	return 0;
}
